package bz.yfw.example.s3blazeds.part2.helper
{
	import bz.yfw.example.s3blazeds.part2.model.view.EmpViewModel;
	import bz.yfw.example.s3blazeds.part2.view.EmpEditConfirmView;
	import bz.yfw.example.s3blazeds.part2.view.EmpEditSecondView;
	import bz.yfw.example.s3blazeds.part2.view.EmpEditView;
	
	import org.seasar.akabana.yui.framework.ns.handler;
	import org.seasar.akabana.yui.framework.ns.viewpart;
	
	import spark.components.RadioButtonGroup;
	import spark.components.TextInput;
	import spark.components.ViewNavigator;
	import spark.components.supportClasses.ViewReturnObject;
	
	use namespace viewpart;
	
	/**
	 * 社員編集1から2へのHelper
	 * @author tokufxug http://twitter.com/tokufxug
	 */ 
	public class EmpEditNextHelper
	{
		public var view:EmpEditView;
		
		viewpart var txtinptName:TextInput;
		viewpart var rdbgrpSex:RadioButtonGroup;
		
		viewpart var txtinptYear:TextInput;
		viewpart var txtinptMonth:TextInput;
		viewpart var txtinptDate:TextInput;
		
		public function get empViewModel():EmpViewModel {
			if (view.viewModel) {
				return view.viewModel;
			}
			return new EmpViewModel();
		}
		
		public function moveNext():void {
			var vm:EmpViewModel = empViewModel;
			
			vm.name = txtinptName.text;
			vm.sex = rdbgrpSex.selectedValue as String;
			vm.year = txtinptYear.text;
			vm.month = txtinptMonth.text;
			vm.date = txtinptDate.text;
			
			view.navigator.pushView(EmpEditSecondView, vm);
		}
	}
}